#{extends 'magicBox.html' /}

#{set 'title'}Sprints (${project.sprints.size()})
#{if connected.in(project).can('addSprint') }
<a onClick="overlayOpen('/Sprints/projectblank?projectId=${project.id}')"href="#" ><img src="@{'public/images/famfam/add.png'}" alt=[+]/></a>
#{/if}
<a href="#" onclick="overlayOpen('@{ProductBacklogs.showgraph(project.id,0)}')" title="View progress of whole company for all sprints?">
<img src="@{'public/images/famfam/chart.png'}" alt="[chart]"/></a>		
#{/set}
<script type="text/javascript">
function isBefore(date){
	var now=new Date();
	var other=new Date(date);
	if(now<other){
	return  true;
		}
	else{
	return false;
		}
}

</script>

	#{list items:sprints, as:'sprint'}
		<div class="${sprint.id == runningSprint ? 'greenBg' : ( sprint.ended ||sprint.endDate.before(new Date()) )? 'redBg' : 'yellowBg'} reload-sprint-${sprint.id}" name="/sprints/showsprint?id=${sprint.id}&projectId=${sprint.project.id}">Sprint ${sprint.sprintNumber}#{if !sprint.ended}#{drop 'sprint-' + sprint.id /}#{/if}<a href="#" onclick="overlayOpen('@{SprintBacklog.show_graph(sprint.id,0)}')" title="view the burndown chart?"><img src="@{'public/images/famfam/chart.png'}" alt=[chart]""/></a>
		<a href="#" onclick="overlayOpen('@{SprintBacklog.index(0,sprint.id)}')" title="View backlog for all components?">
		<img src="@{'public/images/famfam/table.png'}" alt="[chart]"/></a>	
		#{if sprint.ended || sprint.ended()}
			
		#{/if}
		#{else}
			#{if sprint.project.hasComponents()>1}
				<a href="#" onclick="overlayOpen('@{Boards.loadboard1(sprint.id)}')" title="View project board?">
				<img src="@{'public/images/famfam/application_view_tile.png'}"/></a>
			#{/if}
			#{else}
				<a href="#" onclick="overlayOpen('@{Boards.loadboard1(sprint.id,sprint.project.components[0].id)}')" title="View project board?">
				<img src="@{'public/images/famfam/application_view_tile.png'}"/></a>
			#{/else}
		#{/else}
	
	#{if connected.in(sprint.project).can("editSprint")}
		#{if sprint.ended || sprint.ended()}
		<img class="dim"src="/public/images/famfam/pencil.png" />
		#{/if}
		#{else}
		<a href="#" onclick="overlayOpen('@{Sprints.projectshow(sprint.id)}')"><img src="/public/images/famfam/pencil.png" /></a>
		#{/else}
	#{/if}
	
	<!-- countdown -->
	#{if sprint.startDate.after(new Date())}
	<span id="spt_${sprint.id}" class="meeting_countdown"></span>
		<script type="text/javascript">
		$(function() {
			showDate(${sprint.id},'spt_'+${sprint.id},${sprint.startDate.getTime()},"sprint ${sprint.sprintNumber}","sprint");
		})
		</script>	
	#{/if}
	<!-- end countdown -->
	
		</div>
	

#{/list}
#{else}
	#{note}There are No Sprints.#{/note}
#{/else}
